package com.htudata;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j

@SpringBootApplication
public class DataeWebviewServiceApplication  extends SpringBootServletInitializer{

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        SpringApplicationBuilder builder= application.sources(DataeWebviewServiceApplication.class);
        log.info("\n----------------------------------------------------------\n\t" +
                "Datae-Webview   is running! Access URLs:\n\t" +
                "----------------------------------------------------------");
        return builder;
    }

    public static void main(String[] args)   {
        ConfigurableApplicationContext application = SpringApplication.run(DataeWebviewServiceApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = "0.0.0.0";
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
        }
        String port = env.getProperty("server.port");
        String path =env.getProperty("server.servlet.context-path")==null?"":env.getProperty("server.servlet.context-path");
        log.info("\n----------------------------------------------------------\n\t" +
                "OSS-LIVE-SERVICE   is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "----------------------------------------------------------");
    }

}
